﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Win32;
using System.Windows.Forms;

namespace Genom_Project
{
    class config
    {
        public static void params_of_prog()
        {
            try
            {
                RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true);
                string[] keys = key.GetSubKeyNames();
                if (keys.Contains("genome project"))
                {
                    key = key.OpenSubKey("genome project");
                    main_window.lang_of_prog = key.GetValue("Language").ToString();
                    main_window.last_local_bd = key.GetValue("last_local").ToString();
                    main_window.last_net_bd = key.GetValue("last_net").ToString();
                }
                else
                {
                    key = key.CreateSubKey("genome project");
                    key.SetValue("Language", "default");
                    key.SetValue("last_local", " ");
                    key.SetValue("last_net", " ");

                }
            }
            catch(System.Exception err)
            {
                MessageBox.Show(err.Message);
            }

        }

        static public string preobraz(string insert, char A = '1', char G = '2', char T = '3', char C = '4', char D = '5', char I = '6')
        {
            try
            {
                if (insert == "отрицат")
                {
                    return "0";
                }
                if (insert == "полож")
                {
                    return "1";
                }
                if (insert == "М")
                {
                    return "2";
                }
                if (insert == "Ж")
                {
                    return "3";
                }
                if (insert == "AA")
                {
                    return A.ToString() + A.ToString();
                }
                if (insert == "AG")
                {
                    return A.ToString() + G.ToString();
                }
                if (insert == "AC")
                {
                    return A.ToString() + C.ToString();
                }
                if (insert == "GG")
                {
                    return G.ToString() + G.ToString();
                }
                if (insert == "GA")
                {
                    return G.ToString() + A.ToString();
                }
                if (insert == "GT")
                {
                    return G.ToString() + T.ToString();
                }
                if (insert == "GC")
                {
                    return G.ToString() + C.ToString();
                }
                if (insert == "TC")
                {
                    return T.ToString() + C.ToString();
                }
                if (insert == "TG")
                {
                    return T.ToString() + G.ToString();
                }
                if (insert == "CA")
                {
                    return C.ToString() + A.ToString();
                }
                if (insert == "CG")
                {
                    return C.ToString() + G.ToString();
                }
                if (insert == "CT")
                {
                    return C.ToString() + T.ToString();
                }
                if (insert == "TT")
                {
                    return T.ToString() + T.ToString();
                }
                if (insert == "CC")
                {
                    return C.ToString() + C.ToString();
                }
                if (insert == "DD")
                {
                    return D.ToString() + D.ToString();
                }
                if (insert == "II")
                {
                    return I.ToString() + I.ToString();
                }
                if (insert == "ID")
                {
                    return I.ToString() + D.ToString();
                }
            }
            catch
            { return "ОШИБКА ФОРМАТА"; }
            return insert;

        }

        public static string vernyt(string vhod, char A = '1', char G = '2', char T = '3', char C = '4', char D = '5', char I = '6')
        {
            try
            {

                if (vhod == "2")
                {
                    return "М";
                }
                if (vhod == "3")
                {
                    return "Ж";
                }
                if (vhod == "0")
                {
                    return "отрицат";
                }
                if (vhod == "1")
                {
                    return "полож";
                }
                if (vhod == A.ToString() + A.ToString())
                {
                    return "AA";
                }
                if (vhod == A.ToString() + G.ToString())
                {
                    return "AG";
                }
                if (vhod == A.ToString() + C.ToString())
                {
                    return "AC";
                }
                if (vhod == G.ToString() + G.ToString())
                {
                    return "GG";
                }
                if (vhod == G.ToString() + A.ToString())
                {
                    return "GA";
                }
                if (vhod == G.ToString() + T.ToString())
                {
                    return "GT";
                }
                if (vhod == G.ToString() + C.ToString())
                {
                    return "GC";
                }
                if (vhod == T.ToString() + C.ToString())
                {
                    return "TC";
                }
                if (vhod == T.ToString() + G.ToString())
                {
                    return "TG";
                }
                if (vhod == C.ToString() + A.ToString())
                {
                    return "CA";
                }
                if (vhod == C.ToString() + G.ToString())
                {
                    return "CG";
                }
                if (vhod == C.ToString() + T.ToString())
                {
                    return "CT";
                }
                if (vhod == T.ToString() + T.ToString())
                {
                    return "TT";
                }
                if (vhod == C.ToString() + C.ToString())
                {
                    return "CC";
                }
                if (vhod == D.ToString() + D.ToString())
                {
                    return "DD";
                }
                if (vhod == I.ToString() + I.ToString())
                {
                    return "II";
                }
                if (vhod == I.ToString() + D.ToString())
                {
                    return "ID";
                }
            }
            catch
            { return "ОШИБКА ДАННЫХ"; }
            return vhod;
        }

    }
}
